#include "dlg_roomcontrol.h"
#include "ui_dlg_roomcontrol.h"
#include"lib/sql.h"
#include<QMessageBox>
dlg_roomcontrol::dlg_roomcontrol(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::dlg_roomcontrol)
{
    ui->setupUi(this);
}
dlg_roomcontrol::~dlg_roomcontrol()
{
    delete ui;
}
void dlg_roomcontrol::on_btn_add_clicked()
{
    emit this->back();
    QStringList l;
    l<<ui->room_id->text();
    l<<ui->room_used->text();
    l<<ui->room_large->text();
    l<<ui->room_open->text();
    l<<ui->room_close->text();
    l<<ui->room_equiment->text();

    Sql::getinstance()->addRoom(l);

    QMessageBox::information(nullptr,"会议信息","添加成功");

    ui->room_id->clear();
    ui->room_used->clear();
    ui->room_large->clear();
    ui->room_open->clear();
    ui->room_close->clear();
    ui->room_equiment->clear();

    this->close();
}
void dlg_roomcontrol::on_btn_alt_clicked()
{
    emit this->back();
    QStringList l;
    l<<ui->room_id->text();
    l<<ui->room_used->text();
    l<<ui->room_large->text();
    l<<ui->room_open->text();
    l<<ui->room_close->text();
    l<<ui->room_equiment->text();

    Sql::getinstance()->altRoom(l);

    QMessageBox::information(nullptr,"会议信息","修改成功");

    ui->room_id->clear();
    ui->room_used->clear();
    ui->room_large->clear();
    ui->room_open->clear();
    ui->room_close->clear();
    ui->room_equiment->clear();

    this->close();
}
void dlg_roomcontrol::on_btn_cancel_clicked()
{
    this->close();
}
